package com.lookoutthebush.companyindex.util;

import lombok.Data;

/**
 * result
 *
 * @author LookOut
 * @date 2021/9/22 9:14 下午
 */
@Data
public class Result<T> {

    private Integer code;

    private String message;

    private T data;

    public static <U> Result<U> success(String message, U data) {
        Result<U> result = new Result<>();
        result.setCode(0);
        result.setMessage(message);
        result.setData(data);
        return result;
    }

    public static <U> Result<U> success(U data) {
        Result<U> result = new Result<>();
        result.setCode(0);
        result.setMessage("success");
        result.setData(data);
        return result;
    }

    public static <U> Result<U> error(String message) {
        Result<U> result = new Result<>();
        result.setCode(10001);
        result.setMessage(message);
        result.setData(null);
        return result;
    }
}
